<?php
$q=$_GET["q"];
$dates="";
$posts="";
include_once 'Login/databaseconnection.php';
$hint="";
if($q!="")
{
$get_posts=mysql_query("SELECT * FROM posts");
				$num=mysql_num_rows($get_posts);
				while($rowpost=mysql_fetch_array($get_posts))
				{
				if(empty($dates))
				{
				$dates=$rowpost['Event_Date'];
				}
				else
				{
				$dates=$dates.",".$rowpost['Event_Date'];
				}
				if(empty($posts))
				{
				$posts=$rowpost['News'];
				}
				else
				{
				$posts=$posts.",".$rowpost['News'];
				}
				}
				$news=explode(",",$posts);
				$news_dates=explode(",",$dates);
				if($get_posts)
				{
				for($i=($q-1);$i<($q+3);$i++)
				{
				$hint=$hint.'<li><h3>'.$news_dates[$i].'</h3>';
				if($news[$i]!="")
				{
				$hint=$hint.'<p>'.$news[$i].'&#8230;</p></li>';
				}
				}
				}
				if($i<$num)
				{
				$n=$i+1;
				$hint=$hint.'<img src="'.$basedir.'/images/next.png" align="right" onclick="showNextPosts('.$n.')"/>';
              	}
				if($q>=5)
				{
				$p=$q-4;
				$hint=$hint.'<img src="'.$basedir.'/images/back.png" align="left" onclick="showNextPosts('.$p.')"/>';
              	}
}
if($hint=="")
{
$response='';
}
else
{
$response=$hint;
}
echo $response;
?>